#include "../../include/ParticleEngine.hpp"
using namespace klas;

ParticleEngine::ParticleEngine()
{
  m_emitters.clear();
}

ParticleEngine::~ParticleEngine()
{
  for(list<ParticleEmitter*>::iterator it = m_emitters.begin(); it != m_emitters.end(); ++it)
    delete(*it);

  m_emitters.clear();
}

void ParticleEngine::addEmitter(ParticleEmitter* emitter)
{
  m_emitters.push_back(emitter);
}

/*void ParticleEngine::emitParticles(ParticleEmitter* emitter)
{
  if(emitter != 0)
    emitter->emitParticles();
  else
    for(list<ParticleEmitter*>::iterator it = m_emitters.begin(); it != m_emitters.end(); ++it)
      (*it)->emitParticles();
}*/ 

void ParticleEngine::update(Real dt)
{
  for(list<ParticleEmitter*>::iterator it = m_emitters.begin(); it != m_emitters.end(); ++it)
      (*it)->updateParticles(dt);
}

void ParticleEngine::render(const Camera& cam)
{
	
  for(list<ParticleEmitter*>::iterator it = m_emitters.begin(); it != m_emitters.end(); ++it)
      (*it)->render(cam);
}
